/******************************************************************************
Parties and coalition governance in  presidential democracies
Published in Political Research Quarterly


author: Joris Thijm and Jorge M. Fernandes
contact: jorge.fernandes@csic.es
******************************************************************************/

cls
clear all


* Import data
import excel "Final/full.xlsx", firstrow clear

local color = "black " * 15
stplot mesh, colors(`color') ticks(off) background("245 245 245")

encode region, gen(region_enc)
encode presidency, gen(presidency_enc)

* MODEL 1
fmlogit ///
DV1_no_shadowing DV2_partisan_shadowing DV3_nonpartisan_shadowing, cluster(presidency_enc) ///
eta(prestige_enc distance_coalition_mean_log c.presidential_lawmaking_powers_Sh c.age_democracy_last_period##c.age_democracy_last_period margin_victory i.region_enc ENP)


* MODEL 2
fmlogit ///
DV1_no_shadowing DV2_partisan_shadowing DV3_nonpartisan_shadowing, cluster(presidency_enc) ///
eta(prestige_enc distance_coalition_mean_log c.presidential_lawmaking_powers_Sh##c.age_democracy_last_period##c.age_democracy_last_period margin_victory i.region_enc ENP)


sum prestige_enc  distance_coalition_mean_log presidential_lawmaking_powers_Sh age_democracy_cumul_1945 margin_victory if e(sample)



local predict ///
  predict(outcome(DV1_no_shadowing)) ///
  predict(outcome(DV3_nonpartisan_shadowing)) ///
  predict(outcome(DV2_partisan_shadowing))


margins, dydx(distance_coalition_mean_log) `predict'
marginsplot , recast(scatter) yline(0, lp(shortdash)) ///
ytitle("Predicted marginal effect") ///
title("") xlabel(1 `""No" "shadow""' 2 `""Non-partisan" "shadow""' 3 `""Partisan" "shadow""') xtitle("") aspect(1)

graph export "figure1_alt.pdf", replace


* DESCRIÇÃO PODERES PRESIDENTE
margins, at(presidential_lawmaking_powers_Sh = (6(1)12))  predict(outcome(DV3_nonpartisan_shadowing))

marginsplot, recast(line) recastci(rarea) ciopts(fc(%33)) ///
byopts(cols(3) iscale(*0.9)) xsize(*1.2) aspect(1) title("") ytitle("Predicted probability for outcome" "non-partisan shadow") ///
xtitle("Presidential Lawmaking powers" "(Shugart and Carey)") subtitle("")
graph export "figure2_alt.pdf", replace

* DESCRIÇÃO AGE OF DEMOCRACY
margins, dydx(presidential_lawmaking_powers_Sh) at(age_democracy_last_period = (1(1)35)) predict(outcome(DV3_nonpartisan_shadowing))

marginsplot, recast(line) recastci(rarea) ciopts(fc(%33)) ///
yline(0, lp(shortdash)) xlabel(1(5)35) ytitle("Predicted effects") ///
byopts(cols(3) iscale(*0.9)) xsize(*1.2) ///
xtitle("Age of democracy") title("Predicted effects of Presidential Lawmaking Powers (Shugart and Carey)" "on non-partisan shadow, with 95% CIs") aspect(1)


graph export "figure3_alt.pdf", replace


